from django.db import models
from django import forms

# Create your models here.
class User(models.Model):
     login = models.CharField(max_length=20, primary_key=True)
     password = models.CharField(max_length=20, help_text=("Password del usuario"))
     first_name = models.CharField(max_length=50)
     last_name = models.CharField(max_length=50)
     email = models.EmailField(max_length=75)
     date_joined = models.DateTimeField(auto_now_add=True)
     
     def __unicode__(self):
         return self.login

class Admin(models.Model):
     user = models.ForeignKey(User)

class Forum(models.Model):
     name = models.CharField(max_length=100, primary_key=True)
     admin = models.ForeignKey(Admin)
     moder = models.ManyToManyField(User, through='Moderator')
    
     def __unicode__(self):
         return self.name


class Moderator(models.Model):
     user = models.ForeignKey(User)
     forum = models.ForeignKey(Forum)

class Topic(models.Model):
     user = models.ForeignKey('User')
     title = models.CharField(max_length=150)
     pub_date = models.DateTimeField(auto_now=True)
     mod_date = models.DateTimeField(auto_now_add=True)
     thumbtack = models.BooleanField()
     private = models.BooleanField()
     closed = models.BooleanField()	
     content = models.TextField()

     def __unicode__(self):
         return self.title

class Answer(models.Model):
     topic = models.ForeignKey(Topic)
     author = models.ForeignKey(User)
     title = models.CharField(max_length=150)
     pub_date = models.DateTimeField(auto_now=True)
     mod_date = models.DateTimeField(auto_now_add=True)
     content = models.TextField()

     def __unicode__(self):
         return self.title




#class Poll(models.Model):
#    question = models.CharField(max_length=200)
#    pub_date = models.DateTimeField('date published')

#class Choice(models.Model):
#    poll = models.ForeignKey(Poll)
#    choice = models.CharField(max_length=200)
#    votes = models.IntegerField()




